package com.thoughtworks.turtlemock.expression;

import junit.framework.TestCase;

public class ExpressionTest extends TestCase {

    public void testCentimeterPlus() throws Exception {
        Measurement oneCentimeter = Measurement.centimeter(1);
        Expression sum = oneCentimeter.plus(Measurement.centimeter(1));
        assertEquals(Measurement.centimeter(1), oneCentimeter);
        assertEquals(Measurement.centimeter(2), sum.convert(Measurement.CENTIMETER));
    }

    public void testCentimeterEquals() throws Exception {
        assertEquals(Measurement.centimeter(1), Measurement.centimeter(1));
    }

    public void testMillimeterEquals() throws Exception {
        assertEquals(Measurement.millimeter(1), Measurement.millimeter(1));
    }

    public void testMillimeterPlus() throws Exception {
        assertEquals(Measurement.millimeter(1 + 2), Measurement.millimeter(1).plus(Measurement.millimeter(2)).convert(Measurement.MILLIMETER));
    }

    public void testCentimeterPlusMillimeter() throws Exception {
        Measurement oneCentimeter = Measurement.centimeter(1);
        Measurement tenMillimeter = Measurement.millimeter(10);
        Expression sum = oneCentimeter.plus(tenMillimeter);
        assertEquals(Measurement.centimeter(1 + 1), sum.convert(Measurement.CENTIMETER));
        assertEquals(Measurement.millimeter(10 + 10), sum.convert(Measurement.MILLIMETER));
    }
}
